﻿package subject2;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.LineNumberReader;
import java.util.Vector;


import java.awt.*;
import java.awt.event.*;

import javax.swing.*;
import javax.swing.event.*;


import java.util.*;                                        

public class NetworkJFrameStu extends JFrame
{
    private JList<Node> jlistNode; //节点列表框
    private JList<Edge> jlistEdge; //关系列表框
    private JList<Edge> jlistEdgeOneNode;//单个节点对应关系列表框
    private DefaultListModel<Node> listmodelNode; 
    private DefaultListModel<Edge> listmodelEdge;
    private DefaultListModel<Edge> listmodelEdgeOneNode;
    private JButton  loadNodeButton, loadEdgeButton, totalNumButton;
    private JTextField textsNodeNum, textsEdgeNum;  
    
    
    public NetworkJFrameStu() 
    {
        super("网络信息管理");
//        this.setBounds(300,240,740,300);
        this.setSize(740,300);                            
        this.setLocationRelativeTo(null); 
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.getContentPane().setLayout((new GridLayout(1,4)));
        
        this.listmodelNode = new DefaultListModel<Node>();
        this.listmodelEdge = new DefaultListModel<Edge>();
        this.listmodelEdgeOneNode = new DefaultListModel<Edge>();
        this.jlistNode = new JList<Node>(this.listmodelNode); 
        this.jlistEdge = new JList<Edge>(this.listmodelEdge); 
        this.jlistEdgeOneNode = new JList<Edge>(this.listmodelEdgeOneNode);
        
        
        JPanel firstPanel= new JPanel(new BorderLayout());
        firstPanel.add(new JScrollPane(this.jlistNode));
        loadNodeButton = new JButton("导入节点");
        loadNodeButton.setPreferredSize(new Dimension(70,45));
        
        firstPanel.add(loadNodeButton,BorderLayout.SOUTH);
        this.getContentPane().add(firstPanel);
        
        JPanel secondPanel= new JPanel(new BorderLayout());
        secondPanel.add(new JScrollPane(this.jlistEdge));
        loadEdgeButton = new JButton("导入关系");
        loadEdgeButton.setPreferredSize(new Dimension(70,45));
        
        secondPanel.add(loadEdgeButton,BorderLayout.SOUTH);
        this.getContentPane().add(secondPanel);
        
        JPanel thirdPanel= new JPanel(new BorderLayout());
        JPanel upPanel= new JPanel(new GridLayout(5,1));
        thirdPanel.setSize(80, 300);
        upPanel.add(new JLabel("共有"));
        upPanel.add(this.textsNodeNum = new JTextField(0));
        upPanel.add(new JLabel("节点"));
        upPanel.add(this.textsEdgeNum = new JTextField(0));
        upPanel.add(new JLabel("关系"));
        totalNumButton = new JButton("统计数量");
        totalNumButton.setPreferredSize(new Dimension(70,45));
        
        thirdPanel.add(upPanel);
        thirdPanel.add(totalNumButton,BorderLayout.SOUTH);
        this.getContentPane().add(thirdPanel);
        
        
        JPanel FourthPanel= new JPanel(new BorderLayout());
        FourthPanel.add(new JScrollPane(this.jlistEdgeOneNode));
        this.getContentPane().add(FourthPanel);
        
        this.setVisible(true);
    }

   
    

    public static void main(String arg[])
    {
        
        new NetworkJFrameStu();
    }
    
    }